#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
vector<int> to[N];
int f[N], blk;
void init() {
  rep(i, 1, n) f[i] = i;
  blk = n;
}
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
bool merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return false;
  f[fy] = fx;
  return true;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, m) {
    int u, v;
    cin >> u >> v;
    to[u].push_back(v);
    to[v].push_back(u);
  }
  set<int> st;
  init();
  rep(i, 1, n) {
    if (st.count(i)) st.erase(i);
    for (int j : to[i]) {
      if (j <= i) {
        if (merge(i, j)) blk--;
      } else {
        st.insert(j);
      }
    }
    if (blk == n - i + 1)
      cout << st.size() << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}